package IOStream.ConvertStream;

import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;

/**
 * ClassName:Dome003
 * Package:IOStream.ConvertStream
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/3/3-19:03
 * @Version:v1.0
 */
public class Dome003 {
    /*利用转换流按照指定的字符编码写出*/
    public static void main(String[] args) throws IOException {
//        //创建转换流对象
//        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("E:\\aaa\\b.txt"),"GBK");
//        //写出数据
//        osw.write("你好你好");
//        //释放资源
//        osw.close();

        FileWriter fw = new FileWriter("E:\\aaa\\b.txt", Charset.forName("GBK"));
        fw.write("你好你好");
        fw.close();
    }
}
